﻿using System.Web.UI;
using System.Web.UI.WebControls;

namespace BeiXun.Shared.UserControls
{
    public partial class FormTitle : System.Web.UI.UserControl
    {   

        private string _insertTitle, _updateTitle, _readonlyTitle, _title;

        public string InsertTitle
        {
            get
            {
                if (!string.IsNullOrEmpty(_insertTitle))
                {
                    return _insertTitle;
                }
                else
                {
                    return "添加" + _title;
                }
            }

            set
            {
                _insertTitle = value;
            }
        }

        public string UpdateTitle
        {
            get
            {
                if (!string.IsNullOrEmpty(_updateTitle))
                {
                    return _updateTitle;
                }
                else
                {
                    return "修改" + _title;
                }
            }

            set
            {
                _updateTitle = value;
            }
        }

        public string ReadOnlyTitle
        {
            get
            {
                if (!string.IsNullOrEmpty(_readonlyTitle))
                {
                    return _readonlyTitle;
                }
                else
                {
                    return "查看" + _title;
                }
            }

            set
            {
                _readonlyTitle = value;
            }
        }

        public string Title
        {
            get
            {
                return _title;
            }

            set
            {
                _title = value;
            }
        }

        protected override void Render(HtmlTextWriter writer)
        {           
            //BaseFormPage formPage = this.Page as BaseFormPage;
            //string s = string.Empty;
            //if (formPage != null)
            //{
            //    switch (formPage.FormView.CurrentMode)
            //    {
            //        case FormViewMode.Edit:
            //            s = UpdateTitle;
            //            break;
            //        case FormViewMode.Insert:
            //            s = InsertTitle;
            //            break;
            //        case FormViewMode.ReadOnly:
            //            s = ReadOnlyTitle;
            //            break;
            //        default:
            //            break;
            //    }
            //}
            writer.Write(ReadOnlyTitle);
        }
    }
}